package com.liaoban.app.ui.message;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.liaoban.app.constants.ConfigKey;
import com.liaoban.app.helper.ConfigHelper;
import com.liaoban.app.helper.ToastHelper;
import com.liaoban.app.ui.anchor.AnchorDetailActivity;
import com.netease.nim.uikit.api.model.session.SessionCustomization;
import com.netease.nim.uikit.business.session.activity.P2PMessageActivity;
import com.netease.nim.uikit.business.session.constant.Extras;
import com.netease.nimlib.sdk.msg.model.IMMessage;

/**
 * Created by ybc on 2018/8/6 0006.
 */
public class MyP2PMessageActivity extends P2PMessageActivity {
    public static Intent newIntent(Context context, String contactId, SessionCustomization customization, IMMessage anchor) {
        Intent intent = new Intent();
        intent.putExtra(Extras.EXTRA_ACCOUNT, contactId);
        intent.putExtra(Extras.EXTRA_CUSTOMIZATION, customization);
        if (anchor != null) {
            intent.putExtra(Extras.EXTRA_ANCHOR, anchor);
        }
        intent.setClass(context, MyP2PMessageActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        return intent;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        String wuserStatus = ConfigHelper.getString(this, ConfigKey.USER_WUSER_STATUS);
        String tel = ConfigHelper.getString(this, ConfigKey.USER_TEL);
        if ("1".equals(wuserStatus) || "18888999999".equals(tel)) { //是主播
            mIsShowGift = false;
        } else {
            mIsShowGift = true;
        }
        super.onCreate(savedInstanceState);
        ivRight.setOnClickListener(view -> startActivity(AnchorDetailActivity.newIntentImId(this, sessionId)));
    }
}
